package com.scommunity.admin.controller;

import com.scommunity.common.ResponseResult;
import com.scommunity.domain.Emp;
import com.scommunity.domain.Role;
import com.scommunity.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/role")
public class RoleController {
    @Autowired
    private IRoleService roleService;

    @GetMapping("/getAllByEmpId")
    public Object getAllByEmpId(@SessionAttribute Emp emp) {
        List<Role> roles = roleService.getAllByEmpId(emp.getEmpId());
        return ResponseResult.success(roles);
    }

    @GetMapping("/getAll")
    public Object getAll() {
        List<Role> roles = roleService.getAll();
        return ResponseResult.success(roles);
    }

    @GetMapping("/getAllRoles")
    public Object getAllRoles() {
        List<Role> roles = roleService.getAllRoles();
        return ResponseResult.success(roles);
    }

}
